<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">发货通知</p>
    </div>
    <div class="view-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="批次号" prop="batchNumber">
          <el-input
            v-model="queryParams.batchNumber"
            placeholder="请输入批次号回车或者点击搜索按钮"
            clearable
            size="small"
            style="width:230px;"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input
            v-model="queryParams.productName"
            placeholder="请输入产品名称回车或者点击搜索按钮"
            clearable
            size="small"
            style="width:230px;"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="通知状态" prop="status">
          <el-select
            v-model="queryParams.status"
            placeholder="全部"
            clearable
            size="small"
            style="width:100px;"
          >
            <el-option
              v-for="item in status"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
           <el-button type="primary" icon="el-icon-search" size="mini" class="list-search btn-success" color="#5ED4D4"
            @click="handleQuery"
          >搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" class="list-search"
            @click="resetQuery"
          >重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <!-- <el-col :span="1.5">
          <el-button
            class="btn-success"
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="noticeAdd()"
            v-hasPermi="['system:productOutRelease:add']"
          >新建</el-button>
        </el-col> -->
        <!-- oemAdd -->
        <el-col :span="1.5">
          <el-button
            class="btn-success"
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="noticeAdd()"
            v-hasPermi="['system:productOutRelease:addNew']"
          >新建</el-button>
        </el-col>
      </el-row>
      <el-table v-loading="loading" :data="noticeList" @row-click="handleView" border>
        <el-table-column label="序号" type="index" align="center" width="50">
           <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="单据编码" align="center" prop="code" :show-overflow-tooltip="true" width="150" />
        <!-- <el-table-column label="计划编码" align="center" prop="planCode" :show-overflow-tooltip="true" width="150" /> -->
        <el-table-column label="产品名称" align="center" prop="productName" :show-overflow-tooltip="true" />
        <!-- <el-table-column label="产品批号" align="center" prop="batchNumber" :show-overflow-tooltip="true" width="150" /> -->
        <el-table-column label="产品规格" align="center" prop="productSpace" :show-overflow-tooltip="true" />
        <!-- <el-table-column label="入库数量" align="center" prop="store" :show-overflow-tooltip="true" /> -->
        <!-- <el-table-column label="库存数量" align="center" prop="storeNum" :show-overflow-tooltip="true" /> -->
        <el-table-column label="通知数量" align="center" prop="planStoreOut" :show-overflow-tooltip="true" width="80" />
        <!-- <el-table-column label="实际出库" align="center" prop="storeOut" :show-overflow-tooltip="true" /> -->
        <el-table-column label="状态" align="center" prop="status">
          <template slot-scope="scope">
            <div v-if="scope.row.status == 0" style="color:#13C2C2">未通知</div>
            <div v-if="scope.row.status == 1" style="color:#52C41A">已通知</div>
            <!-- <div v-if="scope.row.status == 2" style="color:#52C41A">已撤回</div> -->
          </template>
        </el-table-column>
        <el-table-column label="来源" align="center" prop="generateType">
          <template slot-scope="scope">
            <div v-if="scope.row.generateType == '0'">系统生成</div>
            <div v-if="scope.row.generateType == '1'">手动添加</div>
            <div v-if="scope.row.generateType == '2'">销售订单</div>
            <div v-if="scope.row.generateType == '3'">OEM</div>
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" width="100" />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { listNotice } from "@/api/system/notice/notice";
export default {
  name: "Dict",
  dicts: [],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 字典表格数据
      noticeList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        generateType: '',
        //产品名称
        productName: undefined,
        //批次号
        batchNumber: undefined,
        status: undefined,
        statusName: undefined,
      },
      // 状态
      status:[
        {
          value:'0',
          label:'未通知'
        },
        {
          value:'1',
          label:'已通知'
        }
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表
    getList() {
      this.loading = true
      listNotice(this.addDateRange(this.queryParams)).then((res) => {
        this.noticeList = res.rows
        this.total = res.total
        this.loading = false
      });
    },
    // 搜索按钮
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    // 重置按钮
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 新建
    noticeAdd(){
      // this.$router.push({path:"/notice/add"})
      this.$router.push({path:"/notice/oemAdd"}) // oem发货通知
    },
    // 查看详情
    handleView(row) {
      if(row.generateType == '3'){
        this.$router.push({path:"/notice/oemDetail",query:{id: row.id}})
      }else{
        this.$router.push({path:"/notice/detail",query:{id: row.id}})
      }
    }
  }
};
</script>
